R basics III — functions & packages
2025-02-12
A function is
NULL, may be invisibly)seq(), length() etc are all functions
Functions typically take arguments — options that determine detail of what is done
n is an argument to runif
digits is an argument to round
Arguments can be matched by name or position
Don’t name the first argument but name everything else
R comes with a lot of functions
But it’s not comprehensive
R packages extend R with new functions that implement new statistical methods, utilities, or even entirely new domain specific languages
R packages are user-written and work just like those provided with R
Packages are typically installed from CRAN
Comprehensive R Archive Network
Packages are installed on to a computer into a library
Install a packages using
Load a package each time you want to use it with
(Other repos are available, like GitHub, esp for development versions)